﻿using JX.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace JX.Dapper
{
    /// <summary>
    /// 工作单元工厂实现类
    /// </summary>
    public class DapperUnitOfWorkFactory : IUnitOfWorkFactory
    {
        /// <summary>
        /// 数据库上下文
        /// </summary>
        private readonly DapperDBContext _context;

        /// <summary>
        /// 构造器注入
        /// </summary>
        /// <param name="context">数据库上下文</param>
        public DapperUnitOfWorkFactory(DapperDBContext context)
        {
            _context = context;
        }

        /// <summary>
        /// 创建工作单元
        /// </summary>
        /// <returns></returns>
        public IUnitOfWork Create()
        {
            return new UnitOfWork(_context);
        }
    }
}
